package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.Rule;
import com.indusfo.spc.service.RuleService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/rule")
public class RuleController {
	
	@Autowired
	private RuleService ruleService;

	/**
	 * 新增
	 * @param rule
	 * @return
	 */
	@RequestMapping("insertRule")
	@ResponseBody
	public JSONObject insertRule(Rule rule){
		JSONObject json = ruleService.insertRule(rule) ;
		return json;
	}

	/**
	 * 删除
	 */
	@RequestMapping("/delRule")
	@ResponseBody
	public JSONObject delRule(Integer[] ids, Integer dataState){
		dataState = 2;
		JSONObject json = ruleService.delRule(ids,dataState);
		return json;
	}

	/**
	 * 修改
	 */
	@RequestMapping("/updateRule")
	@ResponseBody
	public JSONObject updateRule(Rule rule){
		JSONObject json = ruleService.updateRule(rule);
		return json;
	}


	/**
	 *
	 * 查询
	 * @param rule
	 * @return
	 */
	@RequestMapping("/queryRule")
	@ResponseBody
	public JSONObject queryRule(Rule rule){
		JSONObject json = ruleService.queryRule(rule);
		return json;
	}
}
